<template>
	<view>
		<uni-list-chat :title="titleSlice(curSkuData?.name ?? '')"
			:avatar="sConf.cos + (curSkuData?.icon ??'/media/default/default.png')" :note="curSkuData?.created">
		</uni-list-chat>
	</view>
</template>

<script>
	import psMethod from '@/common/psMethod';
	export default {
		data() {
			return {
				sConf: getApp().globalData,
				curSkuData: null
			}
		},
		mounted() {
			this.refresh()
		},
		props: {
			sku: {
				type: Number,
				default: null
			}
		},
		methods: {
			titleSlice(e, l = 12) {
				if (e.length > l) {
					return e.slice(0, l) + '...'
				} else {
					return e
				}
			},
			refresh() {
				console.log('refresh');
				let sku = this.sku
				let token = this.sConf.auth.token || '';
				psMethod.syncAuthenticatorRequest(`/admin/cargoSku/${sku}/`, 'GET', token).then(res => {
					console.log('加载SKU', res);
					this.curSkuData = res.resmsg
				})
			},
		}
	}
</script>

<style>

</style>